package com.ccrfid.rmc6.ws;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;


@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
    private static final String NAMESPACE_URI = "http://WebService.service.ccrfid.com/";

    @Bean(name = "helloService")
    public DefaultWsdl11Definition defaultWsdl11Definition2(XsdSchema xsdSchema) {
        DefaultWsdl11Definition wsdl = new DefaultWsdl11Definition();
        wsdl.setPortTypeName("studentResource");
        wsdl.setLocationUri("http://localhost:10001/services/helloService");
        wsdl.setTargetNamespace("http://helloworld.com/example");
        wsdl.setSchema(xsdSchema);
        return wsdl;
    }

    @Bean
    public XsdSchema helloSchema() {
        return new SimpleXsdSchema(new ClassPathResource("META-INF/xsd/example.xsd"));
    }

    @Bean(name = "CcmsCardReaderServer")
    public SimpleWsdl11Definition cardReaderServerWsdl() {
        SimpleWsdl11Definition wsdl = new SimpleWsdl11Definition();
        wsdl.setWsdl(new ClassPathResource("META-INF/wsdl/CcmsCardReaderServer.xml"));
        return wsdl;
    }

}
